package practice_7_23;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {

    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static Read in = new Read();

    /**
     * 平方数
     * @param args
     */
    public static void main1(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long a = (long)Math.sqrt(x);
        long y = a * a;
        if (Math.abs(x - a * a) > Math.abs(x - (a + 1) * (a + 1))) {
            y = (a + 1) * (a + 1);
        }
        System.out.println(y);
    }

    static Map<Integer, Integer> hash = new HashMap<>();

    /**
     * 分组
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] nums = new int[n];
        int maxCount = 0;
        for(int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
            hash.put(nums[i], hash.getOrDefault(nums[i], 0) + 1);
            maxCount = Math.max(maxCount, hash.get(nums[i]));
        }
        if (hash.size() > m) {
            System.out.println(-1);
        } else {
            int left = 1, right = maxCount;
            while(left < right) {
                int mid = (left + right) / 2;
                if (check(mid, m)) {
                    right = mid;
                } else {
                    left = mid + 1;
                }
            }
            System.out.println(left);
        }
    }
    // 一组最多 x 个人, 最多分成 m 组
    public static boolean check(int x, int m) {
        int count = 0;
        for(int key: hash.keySet()) {
            count += hash.get(key) / x + (hash.get(key) % x == 0 ? 0: 1);
        }
        return count <= m;
    }
}

class Read {
    StringTokenizer st = new StringTokenizer("");
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    public String next() throws IOException {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(bf.readLine());
        }
        return st.nextToken();
    }

    public String nextLine() throws IOException {
        return bf.readLine();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}
